# -------------------------------------------------------------------
#       -*- coding: utf-8 -*-
#   @Project    :   spider
#   @File       :   31_用户登陆_处理cookies.py
#   @Author     :   WANGYU
#   @Time       :   2021-08-18 20:38:29
#   @Software   :   PyCharm
#   @Desc       :   登陆17k小说网
# -------------------------------------------------------------------


# 登陆 》得到cookie
# 带着cookie去请求到书架 》书架上到内容
# 两个操作连起来
# 可以使用session进行请求 》session可以是连串到请求，在这个过程中cookie不会丢失
import requests

session = requests.session()
data = {
    'loginName': '19997305922',
    'password': 'admin12345'
}
# 登陆
url = 'https://passport.17k.com/ck/user/login'
resp = session.post(url, data=data)
resp.encoding = 'utf-8'
print('返回登陆------------------------------')
print(resp.text)
# print(resp.cookies)

# 拿书架上到数据
resp2=session.get('https://user.17k.com/ck/author/shelf?page=1&appKey=2406394919')
print('返回书架------------------------------')
# print(resp2.json())
print(resp2.text)